home *** CD-ROM | disk | FTP | other *** search
- unit SysStatus;
- {
- TSystemStatus component unit
- Author: David W. Body / Big Creek Software
- E-mail address: davidbody@bigcreek.com
- Original Version: September 1, 1997
- Last Updated: October 11, 1997
- This code is hereby placed in the public domain.
- }
-
- interface
-
- uses
- Windows, Classes;
-
- type
-
- TSystemStatus = class(TComponent)
- private
- FComputerName: string;
- FUserName: string;
- FMajorVersion: integer;
- FMinorVersion: integer;
- FBuildNumber: integer;
- FPlatformID: integer;
- FTotalPhys: integer;
- FAvailPhys: integer;
- FTotalPageFile: integer;
- FAvailPageFile: integer;
- FTotalVirtual: integer;
- FAvailVirtual: integer;
- public
- procedure GetSystemStatus;
- procedure DisplaySystemStatus(Strings: TStrings);
- published
- property ComputerName: string read FComputerName write FComputerName;
- property UserName: string read FUserName write FUserName;
- property MajorVersion: integer read FMajorVersion write FMajorVersion;
- property MinorVersion: integer read FMinorVersion write FMinorVersion;
- property BuildNumber: integer read FBuildNumber write FBuildNumber;
- property PlatformID: integer read FPlatformID write FPlatformID;
- property TotalPhys: integer read FTotalPhys write FTotalPhys;
- property AvailPhys: integer read FAvailPhys write FAvailPhys;
- property TotalPageFile: integer read FTotalPageFile write FTotalPageFile;
- property AvailPageFile: integer read FAvailPageFile write FAvailPageFile;
- property TotalVirtual: integer read FTotalVirtual write FTotalVirtual;
- property AvailVirtual: integer read FAvailVirtual write FAvailVirtual;
- end;
-
- implementation
-
- uses
- SysUtils;
-
- const
- SComputerName = 'Computer name: %s';
- SUserName = 'User name: %s';
- SOSVersion = 'OS Version: %d.%d';
- SBuildNumber = 'Build number: %d';
- SPlatform = 'Platform: %s';
- SWin32S = 'Win32S';
- SWin95 = 'Windows 95';
- SWinNT = 'Windows NT';
- STotalPhys = 'Total physical memory: %d bytes';
- SAvailPhys = 'Available physical memory: %d bytes';
- STotalPageFile = 'Total page file size: %d bytes';
- SAvailPageFile = 'Available page file memory: %d bytes';
- STotalVirtual = 'Total virtual memory: %d bytes';
- SAvailVirtual = 'Available virtual memory: %d bytes';
-
- procedure TSystemStatus.GetSystemStatus;
- var
- ComputerName: array[0..MAX_COMPUTERNAME_LENGTH] of char;
- UserName: array[0..8] of char;
- length: integer;
- OSVersionInfo: TOSVersionInfo;
- MemoryStatus: TMemoryStatus;
- begin
- length := SizeOf(ComputerName);
- if GetComputerName(@ComputerName, length) then
- FComputerName := StrPas(@ComputerName)
- else
- FComputerName := 'Unknown';
-
- length := SizeOf(UserName);
- if GetUserName(@UserName, length) then
- FUserName := StrPas(@UserName)
- else
- FUserName := 'Unknown';
-
- OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);
- GetVersionEX(OSVersionInfo);
- with OSVersionInfo do
- begin
- FMajorVersion := dwMajorVersion;
- FMinorVersion := dwMinorVersion;
- FBuildNumber := LoWord(dwBuildNumber);
- FPlatformID := dwPlatformID;
- end;
-
- MemoryStatus.dwLength := SizeOf(MemoryStatus);
- GlobalMemoryStatus(MemoryStatus);
- with MemoryStatus do
- begin
- FTotalPhys := dwTotalPhys;
- FAvailPhys := dwAvailPhys;
- FTotalPageFile := dwTotalPageFile;
- FAvailPageFile := dwAvailPageFile;
- FTotalVirtual := dwTotalVirtual;
- FAvailVirtual := dwAvailVirtual;
- end;
- end;
-
- procedure TSystemStatus.DisplaySystemStatus(Strings: TStrings);
- begin
- with Strings do
- begin
- Clear;
- Add(Format(SComputerName, [ComputerName]));
- Add(Format(SUserName, [UserName]));
- Add(Format(SOSVersion, [MajorVersion, MinorVersion]));
- Add(Format(SBuildNumber, [BuildNumber]));
- case PlatformID of
- VER_PLATFORM_WIN32S: Add(Format(SPlatform, [SWin32S]));
- VER_PLATFORM_WIN32_WINDOWS: Add(Format(SPlatform, [SWin95]));
- VER_PLATFORM_WIN32_NT: Add(Format(SPlatform, [SWinNT]));
- end;
- Add(Format(STotalPhys, [TotalPhys]));
- Add(Format(SAvailPhys, [AvailPhys]));
- Add(Format(STotalPageFile, [TotalPageFile]));
- Add(Format(SAvailPageFile, [AvailPageFile]));
- Add(Format(STotalVirtual, [TotalVirtual]));
- Add(Format(SAvailVirtual, [AvailVirtual]));
- end;
- end;
-
- initialization
-
- RegisterClass(TSystemStatus);
-
- end.
-